<template>
  <div>
    <parent
      v-if="parentData.parent"
      :parentData="parentData.parent"
      @parentCallReply="parentCallReply"
    />
    <div class="parentWrapper">
      <div class="top">
        <div class="info">
          {{ parentData.user.nickname }}
          <span
            class="date"
          >{{ parentData.create_date.split("T")[0] }}</span>
        </div>
        <div class="btn" @click="handleReply">回复</div>
      </div>
      <div class="content">{{ parentData.content }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "parent",
  props: ["parentData"],
  methods: {
    handleReply() {
      this.$emit("parentCallReply", {
        id: this.parentData.id,
        name: this.parentData.user.nickname,
      });
    },
    parentCallReply(parentInfo) {
      this.$emit("parentCallReply", parentInfo);
    },
  },
};
</script>

<style lang="less" scoped>
.parentWrapper {
  border: 1px solid #333;
  padding: 12 / 360 * 100vw;
  margin-top: -1px;
}
.top {
  display: flex;
  .info {
    font-size: 14 / 360 * 100vw;
    flex: 1;
    .date {
      font-size: 12 / 360 * 100vw;
      color: #b2b2b2;
    }
  }
  .btn {
    font-size: 14 / 360 * 100vw;
    color: #888;
  }
}
.content {
  padding-top: 10 / 360 * 100vw;
}
</style>